<script src="<?php echo $socketNode?>socket.io/socket.io.js"></script>
<link href="<?=$baseurl?>public/css/bootstrap.min.css" rel="stylesheet"/>
<!-- MetisMenu CSS -->
<link href="<?=$baseurl?>public/css/plugins/metisMenu/metisMenu.min.css" rel="stylesheet"/>
<!-- Timeline CSS -->
<link href="<?=$baseurl?>public/css/plugins/timeline.css" rel="stylesheet"/>
<!-- Custom CSS -->
<link href="<?=$baseurl?>public/css/sb-admin-2.css" rel="stylesheet"/>
<!-- Morris Charts CSS -->
<link href="<?=$baseurl?>public/css/plugins/morris.css" rel="stylesheet"/>
<!-- Custom Fonts -->
<link href="<?=$baseurl?>public/font-awesome-4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
<!-- Config CSS -->
<link href="<?=$baseurl?>public/css/custom.css" rel="stylesheet"/>
<link href="<?=$baseurl?>public/css/style.css" rel="stylesheet">
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="<?=$baseurl?>public/js/script.js"></script>
<!-- jQuery Version 1.11.0 -->
<script src="<?=$baseurl?>public/js/jquery-1.11.0.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script>
    var $ = jQuery.noConflict();
    var baseUrl  = '<?php echo $baseurl?>';
    var socket = io.connect('<?php echo $socketNode?>');
</script>
<style>
.fix-ajax{
    margin-left: 0px !important;
}
</style>
<div class="rightpanel fix-ajax">
<div class="maincontent">
<?php if(validation_errors()): ?>
    <div class="alert alert-error" style="margin: 10px 10px 10px 40px;">
      <button data-dismiss="alert" class="close" type="button">×</button>
      <?php echo validation_errors(); ?>
    </div>
<?php endif;?>
	<div class="contentinner content-dashboard">
    <?php if(!in_array(@$data, array(null, '', '0'))):?>
    <p style="margin: 10px 5px 10px 0px;font-size: 18px;">
        <center>
            <h2 style="font-family: arial;">Thêm câu hỏi thành công.</h2>
            <h4>Đang tắt popup ...</h4>
            <h3 style="font-family: arial;"><a href="javascript: void(0);" onclick="closes()">Bấm vào đây nếu trình duyệt không tự đóng lại.</a></h>
        </center>
        
        <script>
        $(function()
        {
           socket.emit('socketvote', <?php echo $data->id?>);
           socket.on('success-add-html-close', function(data)
           {
                closes();
                closeIframe();
           });
        });
        </script>
    </p>
    <?php else:?>
        <?php $attr = array('class' => 'stdform'); echo form_open('', $attr)?>
            <input type="hidden" name="id" value="<?php echo $id_tvshow?>" />
    		<div id="add-input-show" style="padding: 10px;">
                <p style="margin: 10px 5px 10px 0px;font-size: 18px;">
                    Nội dung câu hỏi
                        <hr style="border-top: 1px soild #DCDCDC !important;margin: 0px;" />
                </p>
                <p>
                    <span class="field">
                        <textarea name="question" placeholder="Nội dung câu hỏi..." style="width: 100% !important;height: 120px"><?php echo $this->input->post('question');?></textarea>
                    </span>
                </p>
                <p>
                    <label>
                        <input type="checkbox" value="1" name="isshare" /> Cho phép share facebook 
                    </label>
                </p>
                 <p style="margin: 15px 5px 10px 0px;font-size: 18px;">
                    Phương án trả lời
                        <hr style="border-top: 1px soild #DCDCDC !important;margin: 0px;" />
                </p>
        		
        		<p style="margin: 0;float: left;width: 100%;"> 
        			<label style="position: absolute; font-weight: bold">&nbsp;</label>
        			<span class="field" style="">
                        <input type="text" name="choice[]" class="form-control" style="width: 90%;float: left;margin: 5px;" placeholder="Nhập phương án..." value="<?php echo $this->input->post('choice[]');?>"/>
                        
        			</span>
        		</p>
        		
        		<p style="margin: 5px 0 5px 0;float: left;width: 100%;">
                    <span class="field" style="">
                            <input type="text" name="choice[]" class="form-control" style="width: 90%;float: left;margin: 5px;" placeholder="Nhập phương án..." value="<?php echo $this->input->post('choice[]');?>"/>
                            
                            <span class="addinput" style="float: left;width: 8%;padding: 5px;">
                                <button class="btn" type="button" onclick="addinputbtn()">[ + ]</button>
                            </span>
        			</span>
        		</p>   
            </div>
            <p style="text-align: center;padding-top: 50px;">
                <label></label>
                <button class="btn btn-rounded" type="submit"> <i class="iconfa-ok"></i> &nbsp; Thêm</button>
                <button class="btn btn-rounded" type="button" onclick="closeIframe()"> <i class="icon-arrow-right"></i> &nbsp; Đóng lại</button>
            </p>
        </form>
    <?php endif;?>
    
    </div>
</div>
</div>
<script>
function closes()
{
    closeIframe();
}



function addinputbtn()
{
    $(".addinput").html('');
    var html = '<p style="margin: 0;float: left;width: 100%;">'+
		         '<span class="field">'+
                    '<input type="text" name="choice[]"  class="form-control" style="width: 90%;float: left;margin: 5px;" placeholder="Nhập phương án..." value=""/>'+
		              '<span class="addinput" style="float: left;width: 8%;padding: 5px;margin-top: -20px;">'+
                        '&nbsp;<button class="btn" type="button" onclick="addinputbtn()">[ + ]</button>'+
                     '</span>'+
                 '</span>'+
                 
                '</p>';
    $("#add-input-show").append(html);
};
    
</script>